package tx.oopa.circuit.view;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Point;

import javax.swing.JComponent;

import tx.oopa.circuit.node.AbstractNode;

public class NodeDecorator extends NodeComponentDecorator {

    public NodeDecorator(JComponent component) {
        super(component);
        this.setLayout(null);
    }

    @Override
    public void paint(Graphics g) {
        this.component.paint(g);
        // Draw nodes
        for(AbstractNode node : MAP.keySet()) {
            Point p = MAP.get(node);
            NodeComponent nodeComponent = NodeComponentFactory
                    .createNodeComponent(node);
            nodeComponent.setLocation(p);
            nodeComponent.paint(g);
        }
    }

    private boolean containsComponent(Component component) {
        Component[] components = this.getComponents();
        for(Component c : components) {
            if(c.equals(component)) {
                return true;
            }
        }
        return false;
    }

}
